/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

#ifndef NIC_MIG_NPU_INTF_H
#define NIC_MIG_NPU_INTF_H

#include "nic_cfg_comm.h"

enum nic_mig_q_type {
    NIC_MIG_SQ,
    NIC_MIG_RQ,
    NIC_MIG_CMDQ,
    NIC_MIG_MAX,
};

#define SQ_RQ_CTX_SIZE 0x40

#define CTX_BUF_LEN 0x400

#define MAX_CTX_NUM (CTX_BUF_LEN / SQ_RQ_CTX_SIZE)
#define BAT_ARR_LEN 0x100

struct nic_mig_q_ctx {
    union {
        struct {
#if defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
            u32 rsvd : 16;
            u32 queue_type : 2;
            u32 opcode : 1;
            u32 func_id : 13;
#else
            u32 func_id : 13;
            u32 opcode : 1;
            u32 queue_type : 2;
            u32 rsvd : 16;
#endif
        } bs;
        u32 value;
    } dw0;

    union {
        struct {
#if defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
            u32 rsvd : 16;
            u32 queue_num : 8;
            u32 start_queue_id : 8;
#else
            u32 start_queue_id : 8;
            u32 queue_num : 8;
            u32 rsvd : 16;
#endif
        } bs;
        u32 value;
    } dw1;
    u8 queue_ctx[CTX_BUF_LEN];
};

struct nic_mig_sq_stop {
    union {
        struct {
#if defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
            u32 rsvd : 10;
            u32 sq_num : 8;
            u32 is_stop : 1;
            u32 func_id : 13;
#else
            u32 func_id : 13;
            u32 is_stop : 1;
            u32 sq_num : 8;
            u32 rsvd : 10;
#endif
        } bs;
        u32 value;
    } dw;
};

struct nic_mig_cmdq_stop {
    union {
        struct {
#if defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
            u32 rsvd : 10;
            u32 cmdq_num : 8;
            u32 is_stop : 1;
            u32 func_id : 13;
#else
            u32 func_id : 13;
            u32 is_stop : 1;
            u32 cmdq_num : 8;
            u32 rsvd : 10;
#endif
        } bs;
        u32 value;
    } dw;
};

struct nic_mig_update_bat {
    u32 opcode;
    u32 func_id;
    u32 type;
    u8 data[BAT_ARR_LEN];
};

#endif